;; This is an operating system configuration for a VM image.
;; Modify it as you see fit and instantiate the changes by running:
;;;;   guix system reconfigure /etc/config.scm;;
(use-modules (gnu) (guix) (srfi srfi-1))

(use-service-modules desktop networking ssh xorg)

(use-package-modules bootloaders certs fonts nvi
                     package-management wget xorg)

(define vm-image-motd
  (plain-file "motd" "\x1b[1;37mThis is the GNU system.  Welcome!\x1b[0m
;; This instance of Guix is a template for virtualized environments.You can reconfigure the whole system by adjusting /etc/config.scmand running:
  guix system reconfigure /etc/config.scm
Run '\x1b[1;37minfo guix\x1b[0m' to browse documentation.
\x1b[1;33mConsider setting a password for the 'root' and 'guest' \accounts.\x1b[0m"))

(operating-system
  (host-name "gnu")
  (timezone "America/Indiana/Indianapolis")
  (locale "en_US.utf8")
  (keyboard-layout (keyboard-layout "us" "dvorak"
                                    #:options '("ctrl:swapcaps")))
  ;; Label for the GRUB boot menu.
  (label (string-append "GNU Guix " (package-version guix)))
  (firmware '())
  ;; Below we assume /dev/vda is the VM's hard disk.
  ;; Adjust as needed.
  (bootloader (bootloader-configuration
               (bootloader grub-bootloader)
               (target "/dev/vda")
               (terminal-outputs '(console))))
  (file-systems (cons (file-system
                        (mount-point "/")
                        (device "/dev/vda1")
                        (type "ext4"))
                      %base-file-systems))
  (users (cons (user-account
                (name "joshua")
                (comment "GNU Guix Live")
                (password "")                     ;no password
                (group "users")
                (supplementary-groups '("wheel" "netdev"
                                        "audio" "video")))
               %base-user-accounts))
  ;; Our /etc/sudoers file.  Since 'guest' initially has an empty password,
  ;; allow for password-less sudo.
  (sudoers-file (plain-file "sudoers" "\root ALL=(ALL) ALL%wheel ALL=NOPASSWD: ALL\n"))
  (packages (append (list nss-certs wget)
                    %base-packages))
  (services   (append (list
                       ;; Uncomment the line below to add an SSH server.
                       (service openssh-service-type
                                (openssh-configuration
                                 (port-number 2222)))
                       (service endlessh-service-type
                                (endlessh-configuration
                                 (port-number 2222)))
                       ;; Use the DHCP client service rather than NetworkManager.
                       (service dhcp-client-service-type))
                      ;; Remove GDM, ModemManager, NetworkManager, and wpa-supplicant,
                      ;; which don't make sense in a VM.
                      (remove (lambda (service)
                                (let ((type (service-kind service)))
                                  (or (memq type
                                            (list gdm-service-type
                                                  wpa-supplicant-service-type
                                                  cups-pk-helper-service-type
                                                  network-manager-service-type
                                                  modem-manager-service-type))
                                      (eq? 'network-manager-applet
                                           (service-type-name type)))))
                              (modify-services %base-services
                                (login-service-type config =>
                                                    (login-configuration
                                                     (inherit config)
                                                     (motd vm-image-motd)))))))
  ;; Allow resolution of '.local' host names with mDNS.
  (name-service-switch %mdns-host-lookup-nss))
